/**
 */
package umlstatemachine.impl;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

import org.eclipse.emf.ecore.util.EObjectResolvingEList;

import umlstatemachine.CompositeState;
import umlstatemachine.StateMachine;
import umlstatemachine.UmlstatemachinePackage;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Composite State</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link umlstatemachine.impl.CompositeStateImpl#getSubmachine <em>Submachine</em>}</li>
 *   <li>{@link umlstatemachine.impl.CompositeStateImpl#isIsSequential <em>Is Sequential</em>}</li>
 *   <li>{@link umlstatemachine.impl.CompositeStateImpl#isIsOrthogonal <em>Is Orthogonal</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class CompositeStateImpl extends StateImpl implements CompositeState {
	/**
	 * The cached value of the '{@link #getSubmachine() <em>Submachine</em>}' reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getSubmachine()
	 * @generated
	 * @ordered
	 */
	protected EList<StateMachine> submachine;

	/**
	 * The default value of the '{@link #isIsSequential() <em>Is Sequential</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #isIsSequential()
	 * @generated
	 * @ordered
	 */
	protected static final boolean IS_SEQUENTIAL_EDEFAULT = true;

	/**
	 * The cached value of the '{@link #isIsSequential() <em>Is Sequential</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #isIsSequential()
	 * @generated
	 * @ordered
	 */
	protected boolean isSequential = IS_SEQUENTIAL_EDEFAULT;

	/**
	 * The default value of the '{@link #isIsOrthogonal() <em>Is Orthogonal</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #isIsOrthogonal()
	 * @generated
	 * @ordered
	 */
	protected static final boolean IS_ORTHOGONAL_EDEFAULT = false;

	/**
	 * The cached value of the '{@link #isIsOrthogonal() <em>Is Orthogonal</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #isIsOrthogonal()
	 * @generated
	 * @ordered
	 */
	protected boolean isOrthogonal = IS_ORTHOGONAL_EDEFAULT;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected CompositeStateImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return UmlstatemachinePackage.Literals.COMPOSITE_STATE;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<StateMachine> getSubmachine() {
		if (submachine == null) {
			submachine = new EObjectResolvingEList<StateMachine>(StateMachine.class, this, UmlstatemachinePackage.COMPOSITE_STATE__SUBMACHINE);
		}
		return submachine;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean isIsSequential() {
		return isSequential;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setIsSequential(boolean newIsSequential) {
		boolean oldIsSequential = isSequential;
		isSequential = newIsSequential;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, UmlstatemachinePackage.COMPOSITE_STATE__IS_SEQUENTIAL, oldIsSequential, isSequential));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean isIsOrthogonal() {
		return isOrthogonal;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setIsOrthogonal(boolean newIsOrthogonal) {
		boolean oldIsOrthogonal = isOrthogonal;
		isOrthogonal = newIsOrthogonal;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, UmlstatemachinePackage.COMPOSITE_STATE__IS_ORTHOGONAL, oldIsOrthogonal, isOrthogonal));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case UmlstatemachinePackage.COMPOSITE_STATE__SUBMACHINE:
				return getSubmachine();
			case UmlstatemachinePackage.COMPOSITE_STATE__IS_SEQUENTIAL:
				return isIsSequential();
			case UmlstatemachinePackage.COMPOSITE_STATE__IS_ORTHOGONAL:
				return isIsOrthogonal();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case UmlstatemachinePackage.COMPOSITE_STATE__SUBMACHINE:
				getSubmachine().clear();
				getSubmachine().addAll((Collection<? extends StateMachine>)newValue);
				return;
			case UmlstatemachinePackage.COMPOSITE_STATE__IS_SEQUENTIAL:
				setIsSequential((Boolean)newValue);
				return;
			case UmlstatemachinePackage.COMPOSITE_STATE__IS_ORTHOGONAL:
				setIsOrthogonal((Boolean)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case UmlstatemachinePackage.COMPOSITE_STATE__SUBMACHINE:
				getSubmachine().clear();
				return;
			case UmlstatemachinePackage.COMPOSITE_STATE__IS_SEQUENTIAL:
				setIsSequential(IS_SEQUENTIAL_EDEFAULT);
				return;
			case UmlstatemachinePackage.COMPOSITE_STATE__IS_ORTHOGONAL:
				setIsOrthogonal(IS_ORTHOGONAL_EDEFAULT);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case UmlstatemachinePackage.COMPOSITE_STATE__SUBMACHINE:
				return submachine != null && !submachine.isEmpty();
			case UmlstatemachinePackage.COMPOSITE_STATE__IS_SEQUENTIAL:
				return isSequential != IS_SEQUENTIAL_EDEFAULT;
			case UmlstatemachinePackage.COMPOSITE_STATE__IS_ORTHOGONAL:
				return isOrthogonal != IS_ORTHOGONAL_EDEFAULT;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (isSequential: ");
		result.append(isSequential);
		result.append(", isOrthogonal: ");
		result.append(isOrthogonal);
		result.append(')');
		return result.toString();
	}

} //CompositeStateImpl
